/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tools;

import java.io.UnsupportedEncodingException;
import java.util.Formatter;
import java.util.Random;

public class Utils {

    public static byte[] concat(byte[] b1, byte[] b2) {
        byte[] b3 = new byte[b1.length + b2.length];
        System.arraycopy(b1, 0, b3, 0, b1.length);
        System.arraycopy(b2, 0, b3, b1.length, b2.length);
        return b3;
    }

    public static byte[] generatePeerId() throws UnsupportedEncodingException {

        byte[] peer_id = new byte[20];
        byte[] version = Parametres.version.getBytes();
        Random random = new Random();

        for (int i = 0; i < version.length; i++) {
            peer_id[i] = version[i];
        }

        String chars = "0123456789";

        for (int i = version.length; i < 20; i++) {
            char carac = chars.charAt(random.nextInt(10));
            peer_id[i] = ((byte) ((int) carac));
        }
        return peer_id;

    }

   

    
}
